<?php
  require '../config.php';
?>
<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="content-type" content="text/html;charset=utf-8" />
		<meta name="author" content="www.frebsite.nl" />
		<meta name="viewport" content="width=device-width initial-scale=1.0 maximum-scale=1.0 user-scalable=yes" />
		<meta name="robots" content="noindex, nofollow" />
		<title>首页 - 后台管理系统</title>
        <link rel="stylesheet" href="../public/css/docs.css" />
</head>
<body>
<div id="page">
   <div id="header">所有博文 - 后台管理系统<a href="#" class="right" id="out"></a></div>
   <div id="a_menu">
   <span id="show_menu"> - 菜单
	   <div id="menu">
		   <ul>
               <li><a href="./func.php">所有文章</a></li>
               <?php
                    
                     $result = mysql_query("select * from catalog");
                     while($row = mysql_fetch_array($result)){
                          echo '<li><a href="'.$row['id'].'" class="catalog">'.$row['name'].'</a></li>';
                     }
               ?>
               <li><a href="./reply.php">回复评论</a></li>
               <li><a href="./msg.php">查看留言</a></li>
           </ul>
	   </div>
	   <form method="get" action="./func.php" id="form1">
          <input type="hidden" name="cid" id="cid" />
       </form>
   </span>
   <span id="addNew"> + 写博客</span></div>
   
   <div id="content">
            <?php
					 $id = $_GET['cid'];
                     if($id == ''){
                          $result1 = mysql_query("select * from article order by id desc limit 20");
					 }else{
                          $result1 = mysql_query("select * from article where cid = ".$id." order by id desc limit 20");
					 }
           while($row = mysql_fetch_array($result1))
		   {
			   echo '<div class="adminblock">';
			   echo '<p>标题 : '.$row['title'] . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:;" data-id="'.$row['id'].'" class="delete">删除</a> | <a href="modify.php?id='.$row['id'].'" class="modify">修改</a></p>';
			   echo  $row['content'];
			   echo '</div>';
           }		  		 
     ?>
   </div>
</div>
<script type="text/javascript" src="../public/js/jquery-1.11.0.min.js"></script>
<script>
$(function(){
	$('#out').bind('click',function(){
		if(confirm('确认离开?')){
            window.location.href = '../index.php';
		}else{
            return;
		}
	});
	$('#show_menu').bind('click',function(){
           $(this).children('div#menu').slideToggle();
	});
	$('.catalog').bind('click',function(){
		var $cid = $(this).attr('href');
		$('#cid').val($cid);
		$('#form1').submit();
		return false;
	});
	$('#addNew').bind('click',function(){
	    window.location.href = 'add.php';
	});
	$('.delete').bind('click',function(){
		var self = $(this);
		if(confirm('确认删除本篇博文?')){
			$.post('./del.php',{id:self.attr('data-id')},function(data){
				if(data){
					alert('已删除!');
					window.location.reload();
				}
			});   
		}
        return false;
	});
})
</script>
</body>
</html>
